const { execSync } = require('child_process');
const path = require('path');

console.log('🚀 开始构建 Android 应用...');

try {
  // 清理之前的构建
  console.log('📦 清理之前的构建...');
  execSync('cd android && ./gradlew clean', { stdio: 'inherit' });

  // 构建 APK
  console.log('🔨 构建 APK...');
  execSync('cd android && ./gradlew assembleRelease', { stdio: 'inherit' });

  console.log('✅ Android 构建完成！');
  console.log('📱 APK 文件位置: android/app/build/outputs/apk/release/app-release.apk');
} catch (error) {
  console.error('❌ Android 构建失败:', error.message);
  process.exit(1);
}